//
//  ARTUserInfoModel.m
//  ChartsDemo
//
//  Created by yunda on 2022/7/7.
//

#import "ARTUserInfoModel.h"

@implementation ARTUserInfoModel

- (NSString *)sexName{
    if (_sex == 1) {
        return @"男";
    }else{
        return @"女";
    }
}

/// 获取当前user
+ (ARTUserInfoModel *)getUser{
    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
    NSData *data = [userDefault objectForKey:ART_Storage_CurrentUser];
    ARTUserInfoModel *currentUser = [NSKeyedUnarchiver unarchiveObjectWithData:data];
    return currentUser;
}

/// 更新当前user
- (void)updateUser{
    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:self];
    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];
    [userDefault setObject:data forKey:ART_Storage_CurrentUser];
    [userDefault synchronize];
    NSLog(@"更新当前user");
}

- (NSString *)description{
    return [NSString stringWithFormat:@"UserInfo:name=%@ phone=%@",_userName,_phonenumber];
}

@end
